<template>
  <div class="filter-container">
    <el-button
      class="filter-item"
      type="primary"
      icon="el-icon-edit"
      @click="handlePublish"
      v-if="listQueryRemark.ifPublish"
    >
      {{ listQueryRemark.add }}
    </el-button>
    <add-dialogue-vue
      :isVisible="listQueryRemark.isAddVisible"
      @updateData="updateData"
      @hide="hide"
    ></add-dialogue-vue>
  </div>
</template>

<script>
import addDialogueVue from "./addDialogue.vue";

export default {
  components: {
    addDialogueVue,
  },
  created(){
    this.judgeIfPublish()
  },
  data() {
    return {
      listQueryRemark: {
        search: "搜索",
        add: "发布公告",
        export: "导出",
        isAddVisible: false,
        ifPublish: true
      },
      listQueryValue: {
      },
    };
  },
  methods: {
    judgeIfPublish(){
      let role = window.localStorage.getItem("roles")
      if(role === "User") this.listQueryRemark.ifPublish = false
    },
    handlePublish(){
      this.listQueryRemark.isAddVisible = true
    },
    updateData() {
      //   /* 修改数据时，将调用$emit（），
      //   把自增结果传给父组件 */
      this.listQueryRemark.isAddVisible = false;
      this.$emit("updateData");
    },
    hide(){      
      this.listQueryRemark.isAddVisible = false;
    }
  },
};
</script>